home *** CD-ROM | disk | FTP | other *** search
/ Merciful 1 / Merciful - Disc 1.iso / software / r / rexx_plus_compiler / rexxpluscompiler2.dms / in.adf / Examples / findchar.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1991-08-28  |  686 b   |  46 lines

  1. /* */
  2.  
  3. parse arg fn
  4.  
  5. if ~(open('test',fn,'r'))
  6. then do
  7.     say "can't open" fn '.'
  8.     exit(10)
  9.     end
  10.  
  11. pos = -200
  12. do while ~eof('test')
  13.     pos = pos + 200
  14.     buff = readch('test',200)
  15.     len = length(buff)
  16.     loc = 1
  17.     do while loc < len
  18.  
  19.         cha1 = pos('1f'x,buff,loc)
  20.         if cha1 ~= 0
  21.         then do
  22.             say "'1f'x found at "cha1+pos
  23.             loc = loc+cha1
  24.             end
  25.  
  26.         char = pos('Copy',buff,loc)
  27.         if char ~= 0
  28.         then do
  29.             char = char
  30.             if (char + loc + 63) > len
  31.             then do
  32.                 char = 63 - (len - (char + loc))
  33.                 pos = pos + 200
  34.                 buff = readch('test',200)
  35.                 len = length(buff)
  36.                 loc = 1
  37.                 cha1 = 1
  38.                 end
  39.             else char = char + 64
  40.             say substr(buff,char,8)
  41.             end
  42.  
  43.         if cha1 = 0 then leave
  44.         end
  45.     end
  46.